#
# sonarqube-6.7.4 服务 
#
# FROM yi/centos7-jdk8u151
FROM yi/centos7-jdk8u151
MAINTAINER Leon

ADD sonarqube-6.7.4.zip /usr/local/
WORKDIR /usr/local/
RUN unzip sonarqube-6.7.4.zip

COPY sonar-l10n-zh-plugin-1.19.jar /usr/local/sonarqube-6.7.4/extensions/plugins/sonar-l10n-zh-plugin-1.19.jar
COPY sonar-typescript-plugin-1.5.0.2122.jar /usr/local/sonarqube-6.7.4/extensions/plugins/sonar-typescript-plugin-1.5.0.2122.jar
COPY sonar-java-plugin-4.10.0.10260.jar /usr/local/sonarqube-6.7.4/extensions/plugins/sonar-java-plugin-4.10.0.10260.jar
COPY sonar.properties  /usr/local/sonarqube-6.7.4/conf/sonar.properties

WORKDIR /usr/local/sonarqube-6.7.4/bin/linux-x86-64
RUN chmod +x /usr/local/sonarqube-6.7.4/bin/linux-x86-64/sonar.sh

# 创建elsearch用户组及elsearch用户（因为启动 elsearch 不能使用root用户）
RUN groupadd elsearch
RUN useradd elsearch -g elsearch -p elasticsearch

#给elsearch文件夹下所有权限，避免因为写日志没有权限而启动失败 没有生效
RUN mkdir /usr/local/sonarqube-6.7.4/elasticsearch/logs
RUN mkdir /usr/local/sonarqube-6.7.4/elasticsearch/data
RUN mkdir /usr/local/sonarqube-6.7.4/extensions/downloads

#更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch
RUN cd /opt
RUN chown -R elsearch:elsearch /usr/local/sonarqube-6.7.4/elasticsearch 

RUN chmod -R 777 /usr/local/sonarqube-6.7.4/

#在非root用户下运行
USER elsearch 
EXPOSE 9200
EXPOSE 9300

COPY supervisord.conf /etc/supervisord.conf
CMD ["/usr/bin/supervisord"]
